package com.aaa.javaweb.servlet;

import com.aaa.javaweb.dao.MeuaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("Meua")
public class MeuaRoleController {
    @Autowired
    private MeuaDao meuaDao;
    @RequestMapping("querymeua")
    //查询所有的菜单
    public String getAllMeua(HttpServletRequest req, HttpSession session){
        List<Map> user = (List<Map>)session.getAttribute("user");
        String jueseid = user.get(0).get("jueseid")+"";

        String imgpath = user.get(0).get("imgpath")+"";
        //List<Map> maps=meuaDao.querymeua();
        List<Map> maps=meuaDao.querymeuaid(jueseid);
        if(maps.size()>0){
            for (Map map : maps) {
                Object id = map.get("id");
                List<Map> maps1=meuaDao.queryid(id);
                map.put("childrens",maps1);
            }
        }
        req.setAttribute("maps",maps);
        req.setAttribute("imgpath",imgpath);
        return "ee";
    }
}
